// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var AU = require("AudioUtils");
cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    /**
     * 开始场景切换到主游戏场景
     */
    toMainScene: function(){
    	AU.inst.playEffect(EFFECT_SELECT1,false);
    	this.node.runAction(cc.fadeOut(1.0));
    	cc.director.loadScene("MainScene");
    },
    
    /**
     * 显示排行榜
     */
    showRankPage: function(){
    	wx.getOpenDataContext().postMessage({
            command: "getRank"//指令
        });
    	var bgRank = cc.find('Canvas/bg_rank');
		bgRank.active = true;
    },
    
    closeRankPage: function(){
    	var bgRank = cc.find('Canvas/bg_rank');
		bgRank.active = false;
    },
    
    /**
     * 显示系统设置
     */
    showSetPage: function(){
    	AU.inst.playEffect(EFFECT_SELECT1,false);
    	var bgSetup = cc.find('Canvas/bg_setup');
		bgSetup.active = true;
    },
    
    closeSetPage: function(){
    	var bgSetup = cc.find('Canvas/bg_setup');
		bgSetup.active = false;
    },


    onLoad () {
		cc.director.preloadScene('MainScene', function () {//预加载MainScene场景
		    cc.log('Next scene preloaded');
		});
		
    },

    start () {

    },

});
